package cd.safe.school.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

public class ImageMienAdapter extends BaseAdapter {
	private Context context;
	private List<Bitmap> lists;

	public ImageMienAdapter(Context context, List<Bitmap> lists) {
		this.context = context;
		this.lists = lists;

	}

	@Override
	public int getCount() {

		return lists.size();
		// return Integer.MAX_VALUE;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;

		if (convertView == null) {

			imageView = new ImageView(context);

			imageView.setAdjustViewBounds(true);

			imageView.setScaleType(ScaleType.CENTER_CROP);

		} else {

			imageView = (ImageView) convertView;

		}
		imageView.setLayoutParams(new Gallery.LayoutParams(
				LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

		imageView.setImageBitmap(lists.get(position));

		return imageView;
	}

}
